﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using ENail.Domain.Core;
using ENail.Domain.Core.Contract.Services;
using ENail.Portal.Web.Models;

namespace ENail.Portal.Web.Controllers
{
    public class NailServiceController: DUALController<NailServiceListViewItem,
                                                       NailServiceViewModel,
                                                       NailService>
    {
        private readonly INailServiceService _nailService;
        private readonly ICategoryService _categoryService;

        public NailServiceController(INailServiceService nailService,
                                    ICategoryService categoryService)
            : base("NailServiceList", 
                   "NailService", 
                   new NailServiceListViewModelMapper(),
                   new NailServiceViewModelMapper(nailService, categoryService))
        {
            _nailService = nailService;
            _categoryService = categoryService;
        }

        protected override List<NailService> GetList()
        {
            return _nailService.GetAllActiveNailServices().ToList();
        }

        protected override NailService Get(int id)
        {
            return _nailService.GetNailService(id);
        }

        protected override void Add(NailService domainModel)
        {
            User user = User as User;
            domainModel.NailSalon = user.NailSalon;

            _nailService.InsertNailService(domainModel);
        }

        protected override void Update(NailService domainModel)
        {
            _nailService.UpdateNailService(domainModel);
        }

        protected override void Delete(NailService domainModel)
        {
            _nailService.DeActivateNailService(domainModel);
        }
    }
}